"""
AIPPT API Configuration
Reference: docs/docmee_docs.md
"""
import os
from typing import Optional


class AIPPTConfig:
    """AIPPT API Configuration Class"""

    # API Base Configuration
    BASE_URL = os.getenv('AIPPT_BASE_URL', 'https://docmee.cn/api')
    TOKEN = os.getenv('AIPPT_TOKEN', '')

    # Request Configuration
    REQUEST_TIMEOUT = 30
    MAX_RETRIES = 3

    # Pagination Configuration
    DEFAULT_PAGE_SIZE = 10
    MAX_PAGE_SIZE = 100

    # Generation Configuration
    DEFAULT_LANGUAGE = 'zh'  # Chinese
    DEFAULT_PAGE_COUNT = 10

    # Supported file types for upload
    SUPPORTED_FILE_TYPES = [
        'doc', 'docx', 'pdf', 'ppt', 'pptx', 'txt', 'md',
        'xls', 'xlsx', 'csv', 'html', 'epub', 'mobi', 'xmind', 'mm'
    ]

    # Max file upload size (50MB)
    MAX_FILE_SIZE = 50 * 1024 * 1024
    MAX_FILES_COUNT = 5

    @classmethod
    def validate_config(cls) -> bool:
        """Validate configuration"""
        if not cls.TOKEN:
            raise ValueError("AIPPT_TOKEN is not set in environment variables")
        return True

    @classmethod
    def get_headers(cls) -> dict:
        """Get default request headers"""
        return {
            'token': cls.TOKEN,
            'Content-Type': 'application/json'
        }

    @classmethod
    def get_multipart_headers(cls) -> dict:
        """Get headers for multipart/form-data requests"""
        return {
            'token': cls.TOKEN
        }
